<?php
//no direct access
defined('_JEXEC') or die( 'Restricted access' );
//import the JController Class
jimport( 'joomla.application.component.model' );


class NvModelEvent extends JModel {
	
	
	
	function getEvent($keyword,$amt){
				$arrayKota = explode(" ",$keyword);
		if($arrayKota[0]=="Kab" || $arrayKota[0]=="Kota" ){
			$keyword2 = $arrayKota[1];
			if($keyword2 == 'Administrasi'){
				$keyword = 'jakarta';
			}			
		}

		


		
		$keyEncoded = urlencode($keyword);
		
		$tesURL = "http://pipes.yahoo.com/pipes/pipe.run?_id=BFbZl7om3hGC5ZQKwjSbTQ&_render=rss&jumlah=".$amt."&location=".$keyEncoded;
		
		
		
		//instantiate data array
		$data = array();
				
		$options['rssUrl'] = $tesURL;
		
		//parse rss object
		$parser =  JFactory::getXMLParser('rss',$options);
		
			
		//initiate data object array
		$data = array();
		$index = 0;
		
		
		//get link,title and image url and store it to an object array
		foreach ($parser->get_items(0,$amt) as $item){
					
			$event = new stdClass();
			$event->title = $item->get_title();
			$event->link = $item->get_link();
			$event->description = $item->get_description();
			$data[$index++] = $event;
						 			
		}
			
	 		
		return $data;
	}
 
}
?>